﻿using System;
using System.ComponentModel;
using System.Windows.Controls;
using OpenAiClient.Models;
using OpenAiClient.ViewModels;

namespace OpenAiClient.Views
{
    /// <summary>
    /// TitleView.xaml 的交互逻辑
    /// </summary>
    // ReSharper disable once RedundantExtendsListEntry
    public partial class TitleView : UserControl
    {
        public event Action OnMinimize = () => { };
        public event Action OnClose = () => { };
        public event Action<MenuType> OnMenuItemClicked = (_) => { };

        public TitleView()
        {
            InitializeComponent();

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                var viewModel = new TitleViewModel();
                viewModel.OnMinimize += () => { OnMinimize.Invoke(); };
                viewModel.OnClose += () => { OnClose.Invoke(); };
                viewModel.OnMenuItemClicked += (menuTag) => OnMenuItemClicked.Invoke(menuTag);
                DataContext = viewModel;
            }
        }
    }
}
